/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Estacionamento.ClassesBasicas;

/**
 *
 * @author Italo Valença
 */
import java.util.*;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.Type;

@Entity
public class Plano {

    @Id
    @GeneratedValue
    private long id;
    private String tipoPlano;
    private double valorPlano;
    private static double baseValor = 6.00;
    private int baseDesconto;
    @OneToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "Cliente_Plano", schema = "estacionamento", joinColumns = @JoinColumn(name = "id_plano"), inverseJoinColumns = @JoinColumn(name = "id_cliente"))
    @Fetch(FetchMode.SELECT)
    @Cascade(CascadeType.SAVE_UPDATE)
    private List<Cliente> cliente;

    public Plano() {

    }

    public Plano(long id, String tipoPlano, double valorPlano, int baseDesconto,
            List<Cliente> cliente) {
        super();
        this.id = id;
        this.tipoPlano = tipoPlano;
        this.valorPlano = valorPlano;
        this.baseDesconto = baseDesconto;
        this.cliente = cliente;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public double getValorPlano() {
        return valorPlano;
    }

    public void setValorPlano(double valorPlano) {
        this.valorPlano = valorPlano;
    }

    public String getTipoPlano() {
        return tipoPlano;
    }

    public void setTipoPlano(String tipoPlano) {
        this.tipoPlano = tipoPlano;
    }

    public List<Cliente> getCliente() {
        return cliente;
    }

    public void setCliente(List<Cliente> cliente) {
        this.cliente = cliente;
    }

    public int getBaseDesconto() {
        return baseDesconto;
    }

    public void setBaseDesconto(int baseDesconto) {
        this.baseDesconto = baseDesconto;
    }

    public static double getBaseValor() {
        return baseValor;
    }

    @Override
    public String toString() {
        return "Plano [id=" + id + ", tipoPlano=" + tipoPlano + ", valorPlano="
                + valorPlano + ", cliente=" + cliente + "]";
    }
}
 